var Random = Mock.Random;
var url = {
    tableDataOne: 'http://livingCategoryListApi',
    loginData: 'http://loginApi',
    test:"http://testData",
    getliveInfo:'http://localhost/streamLive/getStreamLiveList',   //获取直播分类标签接口
    getLiveLabel: 'http://localhost/streamLive/getStreamLiveLabels',   //获取直播分类标签接口
    get_liveList: '../get_liveList.php',   //获取直播分类标签接口
};
var arr = ["精品录播课程","高一数学课程","中学疑难解答","语文课程","英语课程","国学教育","思想教育"];

var imgArr = [
    "./imgs/1482391558235.png",
    "./imgs/1482391768628.png",
    "./imgs/1482391800773.png",
    "./imgs/1482393055128.png",
    "./imgs/1482393309814.png",
    "./imgs/1482393428320.png",
    "./imgs/1482394345278.png"
];

var bannerArr = [
    "./imgs/img_banner1.png",
    "./imgs/img_banner1.png",
    "./imgs/img_banner1.png",
    "./imgs/img_banner1.png"
];

var data = [];
var data2 = [];
var data3 = [];
var data4 = [];

// mockjs api：http://mockjs.com/examples.html

for(var i = 0; i < 8; i ++) { // 可自定义生成的个数
    var template = {
        "id|+1": /[a-z0-9]{32}/,
        'title|1': arr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "information": Random.cparagraph(),
        "chid|+1": /3500000[0-9]/,
        "userid|+1": /[a-z0-9]{32}/,
        "fullname|1": Random.cname(),
        "images|1": imgArr,
        "starttime": Random.date("2019-MM-dd HH:mm:ss"),
        "clicks|1-100": 100,
        "isPrivate":/[10]/
    };
    var template2 = {
        "id|+1": /[a-z0-9]{32}/,
        'title|1': arr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "information": Random.cparagraph(),
        "chid|+1": /3500000[0-9]/,
        "userid|+1": /[a-z0-9]{32}/,
        "fullname|1": Random.cname(),
        "images|1": imgArr,
        "starttime": Random.date("2019-MM-dd HH:mm:ss"),
        "clicks|1-100": 100,
        "isPrivate":/[10]/
    };
    var template3 = {
        "id|+1": /[a-z0-9]{32}/,
        'title|1': arr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "information": Random.cparagraph(),
        "chid|+1": /3500000[0-9]/,
        "userid|+1": /[a-z0-9]{32}/,
        "fullname|1": Random.cname(),
        "images|1": imgArr,
        "starttime": Random.date("2019-MM-dd HH:mm:ss"),
        "clicks|1-100": 100,
        "isPrivate":/[10]/
    }

    data.push(template);
    data2.push(template2);
    data3.push(template3);

}
for(var i = 0; i < 4; i ++) {

    var template4 = {
        "id|+1": /[a-z0-9]{32}/,
        'title|1': arr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "chid|+1": /3500000[0-9]/,
        "images|1": bannerArr,
    }
    data4.push(template4);
}

/*公用接口*/
    //登录接口
    Mock.mock(url.loginData,/post/i, {
        "get_liveList_response": {
            "success": true,
            "resultMessage": "",
            "resultCode": "0000",
            "result": {
                "userid":"4a50210b56817fac9e5d90ef04774d05",
                "username": "user02",
                "fullname": "李白",
                "images":"./imgs/vip.png",
            }
        }
    })
/*公用接口*/


// 分类页接口
Mock.mock(url.tableDataOne,/get|post/i, {
    "live_page_response": {
        "success": true,
        "resultMessage": "",
        "resultCode": "0000",
        "result": [
            {
                "beingLiveList": data,
                "willLiveList":data2,
                "liveRankingList":data3,
                "liveSlideList":data4
            }
        ]
    }
})


/*直播页接口*/


// 直播列表接口
var classData = [];
for(var i = 0; i < 7; i ++){
    var template1 = {
        "id": '@increment()', // 按顺序加1
        'title|+1': labelArr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "displayOrder|+1": /[0-9]/,
        "childList": [
            {
                "id": 6,
                "title": "一年级上学期",
                "displayOrder": 0
            },
            {
                "id": 7,
                "title": "一年级下学期",
                "displayOrder": 0
            }
        ],
    };
    classData.push(template1);
}

Mock.mock(url.getliveInfo,/get|post/i, {
    "status": true,
    "error_code": "",
    "msg": "",
    "data":{
        "pageIndex": 1,
		"pageSize": 12,
		"pageCount": 10,
		"courseList":[
			{
				"courseId": 23,
				"courseName": "会计基础视频教程全套",
				"subjectId": 217,
				"subjectTitle": "会计基础",
				"sourcePrice": 99.00,
				"currentPrice": 88.99,
				"courseTitle": "会计基础重在提供会计工作的基础信息，了解会计的工作原理，掌握会计实务当中必要的理论基础知识。此次视频选择为会计基础科目里难度较高层次水平。",
				"courseLogo": "/images/upload/course/20161222/1482393055128.jpg",
				"buyCount": 22,
				"viewCount": 333,
				"beginTime": "2016/3/29 8:00:00",
				"status": 0,
				"roomId": "35000000",
				"teacherId": 75,
				"teacherName": "魏坤",
				"teacherPic": "/images/upload/teacher/20150915/1442298121626.jpg",
				"isStar": true,
				"education": "资深课程设计专家，专注10年AACTP美国培训协会认证导师",
				"schoolId": 123,
				"schoolName": "关山中学"
            },
        ]
    }
})

// 直播小标签接口
var labelArr = ['全部','一年级','二年级','三年级','四年级','五年级','六年级'];
var subjectArr = ['全部','语文','数学','英语','化学','物理','生物'];
var labelData = [];
var subjectData = [];
var labelChild = [];


for(var i = 0; i < 7; i ++){
    var template1 = {
        "id": '@increment()', // 按顺序加1
        'title|+1': labelArr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "displayOrder|+1": /[0-9]/,
        "childList": [
            {
                "id": 6,
                "title": "一年级上学期",
                "displayOrder": 0
            },
            {
                "id": 7,
                "title": "一年级下学期",
                "displayOrder": 0
            }
        ],
    };

    var template2 = {
        "id":'@increment()', // 按顺序加1
        'title|+1': subjectArr,//从数组 arr 中随机选取 1 个元素，作为最终值。
        "displayOrder|+1": /[0-9]/,
        "childList": [
            {
                "id": 6,
                "title": "一年级上学期",
                "displayOrder": 0
            },
            {
                "id": 7,
                "title": "一年级下学期",
                "displayOrder": 0
            }
        ],
    };
    labelData.push(template1);
    subjectData.push(template2);
}


Mock.mock(url.getLiveLabel,/get|post/i,{
    "status": true,
    "error_code": "",
    "msg": "",
    "data":{
        "gradeList":labelData,
        "subjectList":subjectData
    }
})

/* 直播页接口结束 */